package com.dindang.maintenance.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.constraint.Group;
import android.support.v7.widget.RecyclerView;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.flyco.tablayout.SegmentTabLayout;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import com.dindang.maintenance.di.component.DaggerSendOrderComponent;
import com.dindang.maintenance.di.module.SendOrderModule;
import com.dindang.maintenance.mvp.contract.SendOrderContract;
import com.dindang.maintenance.mvp.presenter.SendOrderPresenter;

import com.dindang.maintenance.R;


import static com.jess.arms.utils.Preconditions.checkNotNull;

@Route(path = "/maintenance/activity/SendOrderActivity")
public class SendOrderActivity extends BaseActivity<SendOrderPresenter> implements SendOrderContract.View {

    ImageView mIvBack;
    TextView mTvTitle;
    SegmentTabLayout mTlHandling;
    EditText mEtAssignedUnitValue;
    Group mGroupAssignedUnit;
    TextView mTvExecutive;
    RecyclerView mRvExecutive;
    ImageView mIvToRight;
    TextView mTvDate;
    TextView mTvStartTime;
    TextView mTvEndTime;
    EditText mEtExplainValue;
    TextView mTvCommit;

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerSendOrderComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .sendOrderModule(new SendOrderModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.maintenance_activity_send_order; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mIvBack = findViewById(R.id.maintenance_iv_back);
        mTvTitle = findViewById(R.id.maintenance_tv_title);
        mTlHandling = findViewById(R.id.maintenance_tl_handling);
        mEtAssignedUnitValue = findViewById(R.id.maintenance_et_assigned_unit_value);
        mGroupAssignedUnit = findViewById(R.id.maintenance_group_assigned_unit);
        mTvExecutive = findViewById(R.id.maintenance_tv_executive);
        mRvExecutive = findViewById(R.id.maintenance_rv_executive);
        mIvToRight = findViewById(R.id.maintenance_iv_to_right);
        mTvDate = findViewById(R.id.maintenance_tv_date);
        mTvStartTime = findViewById(R.id.maintenance_tv_start_time);
        mTvEndTime = findViewById(R.id.maintenance_tv_end_time);
        mEtExplainValue = findViewById(R.id.maintenance_et_explain_value);
        mTvCommit = findViewById(R.id.maintenance_tv_commit);

        mTvTitle.setText("派单");
        mTvTitle.setOnClickListener(v -> finish());
        mIvBack.setOnClickListener(v -> finish());

        mPresenter.init();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public ImageView getIvBack() {
        return mIvBack;
    }

    @Override
    public TextView getTvTitle() {
        return mTvTitle;
    }

    @Override
    public SegmentTabLayout getTlHandling() {
        return mTlHandling;
    }

    @Override
    public EditText getEtAssignedUnitValue() {
        return mEtAssignedUnitValue;
    }

    @Override
    public Group getGroupAssignedUnit() {
        return mGroupAssignedUnit;
    }

    @Override
    public TextView getTvExecutive() {
        return mTvExecutive;
    }

    @Override
    public RecyclerView getRvExecutive() {
        return mRvExecutive;
    }

    @Override
    public ImageView getIvToRight() {
        return mIvToRight;
    }

    @Override
    public TextView getTvDate() {
        return mTvDate;
    }

    @Override
    public TextView getTvStartTime() {
        return mTvStartTime;
    }

    @Override
    public TextView getTvEndTime() {
        return mTvEndTime;
    }

    @Override
    public EditText getEtExplainValue() {
        return mEtExplainValue;
    }

    @Override
    public TextView getTvCommit() {
        return mTvCommit;
    }

    @Override
    public BaseActivity getActivity() {
        return this;
    }
}
